package com.xayy.health.mgt.model;

import cn.kawins.mybatis.base.BaseModel;
import com.xayy.health.mgt.service.strategy.AlgorithmRatedParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import tk.mybatis.mapper.annotation.KeySql;
import tk.mybatis.mapper.code.IdentityDialect;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @author Nie
 * @version V1.0
 * @date 2023/4/10 10:08
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table(name = "HEALTH.health_assess_result")
public class HealthAssessResult extends BaseModel<Long> implements AlgorithmRatedParam<Long> {
    @Id
    @Column(name = "id")
    @KeySql(dialect = IdentityDialect.MYSQL)
    @ApiModelProperty(value = "主键", accessMode = ApiModelProperty.AccessMode.READ_ONLY)
    private Long id;

    @Column(name = "satellite_mid")
    @ApiModelProperty(value = "卫星标识")
    private Long satelliteMid;

    @Column(name = "satellite_name")
    @ApiModelProperty(value = "卫星名称")
    private String satelliteName;

    @Column(name = "parent_id")
    @ApiModelProperty(value = "上级id")
    private Long parentId;

    @Column(name = "node_mid")
    @NotBlank(message = "卫星子节点标识不能为空")
    @ApiModelProperty(value = "卫星子节点标识")
    private Long nodeMid;

    @ApiModelProperty(value = "节点名称")
    @Transient
    private String nodeName;

    @Column(name = "is_component")
    @ApiModelProperty(value = "是否为部件")
    private Boolean isComponent;

    @Column(name = "fault_fraction")
    @NotNull(message = "故障评分不能为空")
    @Min(value = 0, message = "故障评分值应大于等于{value}")
    @Max(value = 100, message = "故障评分值应小于等于{value}")
    @ApiModelProperty(value = "故障评分")
    private Integer faultFraction;

    @Column(name = "nature_fraction")
    @NotNull(message = "性能评分不能为空")
    @Min(value = 0, message = "性能评分值应大于等于{value}")
    @Max(value = 100, message = "性能评分值应小于等于{value}")
    @ApiModelProperty(value = "性能评分")
    private Integer natureFraction;

    @Column(name = "multiple_fraction")
    @ApiModelProperty(value = "综合评分")
    private Integer multipleFraction;

    @ApiModelProperty(value = "满意度")
    private String satisfaction;

    @Column(name = "finish_fraction")
    @ApiModelProperty(value = "是否完成评分")
    private Boolean finishFraction;

    @Column(name = "fraction_time")
    @ApiModelProperty(value = "完成评分时间")
    private Date fractionTime;

    @ApiModelProperty(value = "是否自动评分")
    private Boolean autoScore;

    @Column(name = "fault_weight")
    @ApiModelProperty(value = "故障权重", notes = "0-100")
    private Double faultWeight;

    @Column(name = "scoring_rule")
    @ApiModelProperty(value = "打分规则1：手动2：规则")
    private Integer scoringRule;

    @ApiModelProperty(value = "故障评分介绍")
    @Column(name = "fault_faction_introduction")
    private String faultFactionIntroduction;

    @ApiModelProperty(value = "性能评分介绍")
    @Column(name = "nature_faction_introduction")
    private String natureFactionIntroduction;

    @ApiModelProperty(value = "节点评估权重,0--1,保留两位小数")
    @Column(name = "evaluating_weight")
    private Double evaluatingWeight;

    @Override
    public Long idValue() {
        return id;
    }

    @Override
    public Long obtainNodeId() {
        return nodeMid;
    }

    @Override
    public Integer obtainScore() {
        return multipleFraction;
    }

    @Override
    public void putScore(Integer score) {
        multipleFraction = score;
    }
}
